package cn.itcast.controller;

import cn.itcast.Service.ServiceImpl;
import cn.itcast.pojo.Order;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

@Controller
public class OrderController {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    @Autowired
    private ServiceImpl service;

    public void testSimpleQueue() {
        // 队列名称
        String exchangeName = "itcast.direct";
        // 消息

         Order order= service.getById(101);
        // 发送消息
        rabbitTemplate.convertAndSend(exchangeName, "", order);
    }
}
